import 'package:vista/shared/models/base_frame.dart';

/// 圈子消息拍摄
/// 存储圈子消息信息，如摄影中的拍摄般记录圈子对话
class GroupMessage extends BaseFrame {
  final String id; // 消息ID
  final String groupId; // 圈子ID
  final String userId; // 发送者ID
  final String content; // 消息内容（文本）
  final DateTime timestamp; // 时间戳

  const GroupMessage({
    required this.id,
    required this.groupId,
    required this.userId,
    required this.content,
    required this.timestamp,
  });

  /// 从JSON创建圈子消息拍摄
  factory GroupMessage.fromJson(Map<String, dynamic> json) {
    return GroupMessage(
      id: json['id'] as String,
      groupId: json['groupId'] as String,
      userId: json['userId'] as String,
      content: json['content'] as String,
      timestamp: DateTime.parse(json['timestamp'] as String),
    );
  }

  @override
  List<Object?> get props => [id, groupId, userId, content, timestamp];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'groupId': groupId,
      'userId': userId,
      'content': content,
      'timestamp': timestamp.toIso8601String(),
    };
  }
}
